<template>
  <ul class="dash-ul" v-if="dataList.length > 0">
    <li v-for="item in dataList" :key="item.id">
      <a @click="handleToNotice(item)"
         :style="{ pointerEvents: item.showCircle||!canDisable ? 'auto' : 'none', color: item.showCircle||!canDisable ? '' : 'inherit', textDecoration: item.showCircle||!canDisable ? '' : 'none' }">
        <div v-if="item.showCircle" class="title-circle"></div>
        <div style="width: calc(100% - 16px);">
          <div class="title-content">
            <a-tag v-if="item.showCircle && showUrgent" class="title-urgent">紧急</a-tag>
            <div class="title" :title="item.title">{{ item.title }}</div>
            <a-tag class="ul-tag">{{ item.typeContent }}</a-tag>
          </div>
          <div class="title-time">{{ item.time }}</div>
        </div>
      </a>
    </li>
  </ul>
  <a-empty v-else />
</template>
<script>
export default {
  name: 'DashUl',
  props: {
    dataList: {
      type: Array,
      default: [],
      required: true
    },
    routeJump: {
      type: Function,
      required: true
    },
    showUrgent: {
      type: Boolean,
      default: false
    },
    canDisable: { // 允许不能点击
      type: Boolean,
      default: false
    }
  },
  computed: {},
  data() {
    return {}
  },
  methods: {
    handleToNotice(item) {
      if (item.showCircle||!this.canDisable) {
        this.routeJump(item)
      }
    }
  }
}

</script>

<style scoped lang="less">
.dash-ul {
  padding: 0;
  margin: 0;
  overflow: auto;
  height: 100%;
  font-size: 13px;

  .title-content {
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    align-items: center;
    width: 100%;

    .title-urgent {
      background: -webkit-linear-gradient(-45deg, #FA2820 0%, #FA6800 100%);
      color: white;
      font-size: 11px;
      margin-right: 8px;
      border-radius: 0 5px 0 5px;
      border: unset;
    }

    .title {
      max-width: 85%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      font-weight: normal !important;
      font-size: 13px;
    }

    .ul-tag {
      color: #2d4bae;
      background-color: #dbedff !important;
      border: unset;
      border-radius: 2px;
      margin-left: 5px;
    }
  }

  .title-time {
    font-size: 11px;
    font-weight: normal !important;
    color: rgba(0, 0, 0, 0.4)
  }

  li {
    padding: 0 15px 8px 0;
    list-style: none;
    position: relative;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-height: 40px;

    li:nth-child(even) {
      background-color: #fff;
    }

    a {
      display: flex;
      align-items: flex-start;
      justify-content: flex-start;
      color: rgba(0, 0, 0, 0.8);
      font-weight: 550;
      cursor: pointer;

      .title-circle {
        height: 8px;
        width: 8px;
        border-radius: 4px;
        background-color: #ffb938;
        margin-right: 8px;
        margin-top: 5px;
      }
    }

    a:hover {
      color: #1890FF;
    }
  }
}
</style>